// 模拟数据对象
export const mockUsers = [
  { id: 1, name: '张三', age: 28, role: '管理员', department: '技术部' },
  { id: 2, name: '李四', age: 32, role: '经理', department: '销售部' },
  { id: 3, name: '王五', age: 25, role: '开发者', department: '技术部' },
  { id: 4, name: '赵六', age: 29, role: '设计师', department: '设计部' },
  { id: 5, name: '钱七', age: 34, role: '产品经理', department: '产品部' }
];

// 模拟Dao对象
export const mockDao = {
  add: (entity: string, bean: any) => {
    console.log(`添加 ${entity}:`, bean);
    return Promise.resolve({ ...bean, id: Date.now() });
  },
  update: (entity: string, bean: any) => {
    console.log(`更新 ${entity}:`, bean);
    return Promise.resolve(bean);
  },
  delete: (entity: string, id: string | number) => {
    console.log(`删除 ${entity}, ID: ${id}`);
    return Promise.resolve({ success: true });
  },
  get: (entity: string, id: string | number) => {
    console.log(`获取 ${entity}, ID: ${id}`);
    const user = mockUsers.find(user => user.id === Number(id));
    return Promise.resolve(user || null);
  },
  list: (entity: string) => {
    console.log(`列出所有 ${entity}`);
    return Promise.resolve(mockUsers);
  },
  page: (entity: string, page: number, size: number) => {
    console.log(`分页获取 ${entity}, 页码: ${page}, 每页数量: ${size}`);
    const start = (page - 1) * size;
    const end = start + size;
    const data = mockUsers.slice(start, end);
    return Promise.resolve({
      data,
      total: mockUsers.length,
      page,
      size
    });
  }
};

// 模拟元数据视图
export const mockMetaView = {
  code: 'user',
  name: '用户',
  fields: [
    { code: 'id', name: 'ID', type: 'number', hidden: true },
    { code: 'name', name: '姓名', type: 'string', required: true },
    { code: 'age', name: '年龄', type: 'number' },
    { code: 'role', name: '角色', type: 'string' },
    { code: 'department', name: '部门', type: 'string' }
  ]
}; 